home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / polygon.c < prev    next >
Text File  |  1993-12-06  |  2KB  |  66 lines

  1. /**
  2.  ** POLYGON.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "grx.h"
  25. #include "libgrx.h"
  26.  
  27. void _GrDrawPolygon(int n,int pt[][2],
  28.     int do_close,
  29.     int is_XOR_color,
  30.     _GrPixelDrawProc cornerproc,
  31.     _GrLineDrawProc  lineproc,
  32.     void *fillarg)
  33. {
  34.     int ii;
  35.     MOUSE_FLAG;
  36.  
  37.     MOUSE_BLOCK(CURC,_GrLoX,_GrLoY,_GrHiX,_GrHiY);
  38.     if((n <= 2) ||
  39.        ((do_close != FALSE) &&
  40.         (pt[0][0] == pt[n-1][0]) &&
  41.         (pt[0][1] == pt[n-1][1]) &&
  42.         (--n == 2))) {
  43.         if(n <= 1) {
  44.         if(n > 0) (*cornerproc)(pt[0][0],pt[0][1],fillarg);
  45.         MOUSE_UNBLOCK();
  46.         return;
  47.         }
  48.         (*lineproc)(pt[0][0],pt[0][1],pt[1][0],pt[1][1],fillarg);
  49.         MOUSE_UNBLOCK();
  50.         return;
  51.     }
  52.     for(ii = 0; ii < (n - 1); ii++) {
  53.         (*lineproc)(pt[ii][0],pt[ii][1],pt[ii+1][0],pt[ii+1][1],fillarg);
  54.         if((ii > 0) && is_XOR_color) (*cornerproc)(pt[ii][0],pt[ii][1],fillarg);
  55.     }
  56.     if(do_close) {
  57.         (*lineproc)(pt[ii][0],pt[ii][1],pt[0][0],pt[0][1],fillarg);
  58.         if(is_XOR_color) {
  59.         (*cornerproc)(pt[ii][0],pt[ii][1],fillarg);
  60.         (*cornerproc)(pt[0][0],pt[0][1],fillarg);
  61.         }
  62.     }
  63.     MOUSE_UNBLOCK();
  64. }
  65.  
  66.